package css.core;
import java.util.Random;

public abstract class Staff {

	private int workingTime;
	private boolean isIdle;  // the working status of the staff
	private int startWorkTime;
	private int endWorkTime;
	private int servingID; // the ID of the customer/order it is working on
	private int minOrderTime;
	private int maxOrderTime;
	
	/**
	 *  Constructor of a Staff class 
	 */
	public Staff(int min, int max){
		this.workingTime = 0;
		this.setIdle(true);
		this.setStartWorkTime(0);
		this.endWorkTime = 0;
		this.setServingID(0);
		this.minOrderTime = min;
		this.maxOrderTime = max;
	}
	
	
	/**  
	 * Generate the time needed for a new order
	 * @param min  The minimum time needed for the order, read from the user input
	 * @param max  The maximum time needed for the order, read from the user input
	 * @return  The order time for current order
	 */
	public int orderTime(int min, int max){
		Random random = new Random();
		int currentOrderTime = min + random.nextInt(max-min);
		return currentOrderTime;
	}
	
	
	/**
	 * Show whether the staff has finished his work
	 * @param timer  the current time
	 * @return true if the staff has finished his work
	 */
	public boolean workDone(int timer) {
		// TODO Auto-generated method stub
		return (this.endWorkTime == timer);
	}

	/**
	 * 	End working, switch status to idle and record the working time for current order
	 */
	public void endWork() {
		// TODO Auto-generated method stub
		this.isIdle = true;
		this.workingTime += this.endWorkTime - this.startWorkTime;
	}

//Auto generated getters and setters for private variables
	
	public int getWorkingTime() {
		return workingTime;
	}

	public void setWorkingTime(int workingTime) {
		this.workingTime = workingTime;
	}
	
	public boolean isIdle() {
		return isIdle;
	}

	public void setIdle(boolean isIdle) {
		this.isIdle = isIdle;
	}

	/**
	 * @return the servingID
	 */
	public int getServingID() {
		return servingID;
	}

	/**
	 * @param servingID the servingID to set
	 */
	public void setServingID(int servingID) {
		this.servingID = servingID;
	}

	/**
	 * @return the startWorkTime
	 */
	public int getStartWorkTime() {
		return startWorkTime;
	}

	/**
	 * @param startWorkTime the startWorkTime to set
	 */
	public void setStartWorkTime(int startWorkTime) {
		this.startWorkTime = startWorkTime;
	}
	
	public int getEndWorkTime() {
		return endWorkTime;
	}

	public void setEndWorkTime(int endWorkTime) {
		this.endWorkTime = endWorkTime;
	}

	public int getMinOrderTime() {
		return minOrderTime;
	}

	public void setMinOrderTime(int minOrderTime) {
		this.minOrderTime = minOrderTime;
	}

	public int getMaxOrderTime() {
		return maxOrderTime;
	}

	public void setMaxOrderTime(int maxOrderTime) {
		this.maxOrderTime = maxOrderTime;
	}
}
